package com.ruoyi.develop.goodsSaleMaterialChild.service.impl;

import java.util.List;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.DateUtils;
        import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.ruoyi.develop.goodsSaleMaterialChild.mapper.GoodsSaleMaterialChildMapper;
import com.ruoyi.develop.goodsSaleMaterialChild.domain.GoodsSaleMaterialChild;
import com.ruoyi.develop.goodsSaleMaterialChild.service.IGoodsSaleMaterialChildService;

/**
 * 领料单明细Service业务层处理
 * @author lmm
 * @date 2025-08-18
 */
@Service
public class GoodsSaleMaterialChildServiceImpl implements IGoodsSaleMaterialChildService {
    @Resource
    private GoodsSaleMaterialChildMapper goodsSaleMaterialChildMapper;

    /**
     * 查询领料单明细
     * @param id 领料单明细主键
     * @return 领料单明细
     */
    @Override
    public GoodsSaleMaterialChild selectById(String id) {
        return goodsSaleMaterialChildMapper.selectById(id);
    }

    /**
     * 查询领料单明细列表
     * @param entity 领料单明细
     * @return 领料单明细
     */
    @Override
    public List<GoodsSaleMaterialChild> selectList(GoodsSaleMaterialChild entity) {
        return goodsSaleMaterialChildMapper.selectList(entity);
    }

    /**
     * 新增领料单明细
     * @param entity 领料单明细
     * @return 结果
     */
    @Override
    public int insert(GoodsSaleMaterialChild entity) {
        if(StringUtils.isBlank(entity.getId())){
            entity.setId(IdUtils.fastSimpleUUID());
        }
                entity.setCreateBy(SecurityUtils.getUsername());
                entity.setCreateTime(DateUtils.getNowDate());
            return goodsSaleMaterialChildMapper.insert(entity);
    }

    /**
     * 修改领料单明细
     * @param entity 领料单明细
     * @return 结果
     */
    @Override
    public int update(GoodsSaleMaterialChild entity) {
                entity.setUpdateBy(SecurityUtils.getUsername());
                entity.setUpdateTime(DateUtils.getNowDate());
        return goodsSaleMaterialChildMapper.update(entity);
    }

    /**
     * 批量删除领料单明细
     * @param ids 需要删除的领料单明细主键
     * @return 结果
     */
    @Override
    public int deleteByIds(String[] ids) {
        return goodsSaleMaterialChildMapper.deleteByIds(ids);
    }

    /**
     * 删除领料单明细信息
     * @param id 领料单明细主键
     * @return 结果
     */
    @Override
    public int deleteById(String id) {
        return goodsSaleMaterialChildMapper.deleteById(id);
    }
}
